/**
 * Copyright (c) 2016 coderyuan.com. All Rights Reserved.
 *
 * EShop
 *
 * ResponseUtil.java created on 下午6:09
 *
 * @author yuanguozheng
 * @version 1.0.0
 * @since 16/3/1
 */
package com.coderyuan.web.api.kit.utils;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.coderyuan.web.api.kit.common.Constants;

/**
 * 操作原生响应工具类
 *
 * @author yuanguozheng
 */
public class ResponseUtil {

    public static void write(HttpServletResponse res, Object obj) throws IOException {
        res.setStatus(200);
        res.setContentType(Constants.RESPONSE_MIME);
        res.setCharacterEncoding(Constants.CHARSET);
        PrintWriter writer = res.getWriter();
        writer.write(JsonUtil.toJson(obj));
    }
}
